const AppConfig = {};

AppConfig.BaseUrl = ''; //根Url
AppConfig.RequestTimeout = 5000; //请求超时

AppConfig.TaoBao = 0;
AppConfig.JinDong = 1;
AppConfig.PingDuoDuo = 2;

AppConfig.ZhongHe = 0; //综合
AppConfig.New = 1; //最新
AppConfig.SalesHeight = 2; //销量（高到低）
AppConfig.SalesLow = 3; //销量（低到高）
AppConfig.PriceHeight = 4; //价格(低到高)
AppConfig.PriceLow = 5; //价格（高到低）
AppConfig.CommissionHeight = 6; //佣金比例（高到低）

//通过类型获取名称
AppConfig.GetTypeStr = (t) => {
  if (t === AppConfig.TaoBao) {
    return '淘宝';
  }
  if (t === AppConfig.JinDong) {
    return '京东';
  }
  if (t === AppConfig.PingDuoDuo) {
    return '拼多多';
  }
  return '淘宝';
};

//通过排列获取拼多多对于sort
AppConfig.GetPingDuoDuoSortType = (sort) => {
  switch (sort) {
    case AppConfig.ZhongHe:
      sort = 0;
      break;
    case AppConfig.New:
      sort = 17; //店铺物流评分升序;
      break;
    case AppConfig.SalesHeight:
      sort = 5; //按销量升序
      break;
    case AppConfig.SalesLow:
      sort = 4; //按价格降序
      break;
    case AppConfig.PriceHeight:
      sort = 9;
      break;
    case AppConfig.PriceLow:
      sort = 10;
      break;
    default:
      sort = 0;
      break;
  }
  return sort;
};

//京东——京享
AppConfig.GetJinXiangSortType_JinDong = (sort1) => {
  var item = {};
  switch (sort1) {
    case AppConfig.ZhongHe:
      item.sort = 6;
      item.orderByType = 'asc';
      break;
    case AppConfig.New:
      item.sort = 2;
      item.orderByType = 'asc';
      break;
    case AppConfig.SalesHeight:
      item.sort = 1;
      item.orderByType = 'asc';
      break;
    case AppConfig.SalesLow:
      item.sort = 1;
      item.orderByType = 'desc';
      break;
    case AppConfig.PriceHeight:
      item.sort = 5;
      item.orderByType = 'asc';
      break;
    case AppConfig.PriceLow:
      item.sort = 5;
      item.orderByType = 'desc';
      break;
    default:
      item.sort = 2;
      item.orderByType = 'asc';
      break;
  }
  return item;
};

export default AppConfig;
